//
//  LKLoginViewController.m
//  LKIntelligentVideoProject
//
//  Created by she1323 on 2018/11/6.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKLoginViewController.h"
#import "LKTabbarControllerConfig.h"
#import "LKUserInfor.h"
#import "LKUserInforTool.h"
#import <AFNetworking.h>
#import "LKLockScanViewController.h"
#import "LKPushSetModel.h"
@interface
LKLoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userNameTf;
@property (weak, nonatomic) IBOutlet UITextField *secrectTf;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;

@end

@implementation LKLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.loginBtn.layer.cornerRadius = 5;
    self.loginBtn.layer.masksToBounds = YES;
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)scanAction:(id)sender {
    //设置扫码区域参数
//    LBXScanViewStyle *style = [[LBXScanViewStyle alloc]init];
//    style.centerUpOffset = 44;
//    style.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle_Inner;
//    style.photoframeLineW = 3;
//    style.photoframeAngleW = 18;
//    style.photoframeAngleH = 18;
//    style.isNeedShowRetangle = NO;
//    style.anmiationStyle = LBXScanViewAnimationStyle_LineMove;
//    
//    //qq里面的线条图片
//    UIImage *imgLine = [UIImage imageNamed:@"CodeScan.bundle/qrcode_scan_light_green"];
//    style.animationImage = imgLine;
//    
//    style.notRecoginitonArea = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
//    LKLockScanViewController *vc = [[LKLockScanViewController alloc] init];
//    vc.style = style;
//    vc.isOpenInterestRect = YES;
//    vc.libraryType = SLT_Native;
//    vc.hidesBottomBarWhenPushed = YES;
//    UINavigationController *navVc = [[UINavigationController alloc] initWithRootViewController:vc];
//    [self presentViewController:navVc animated:YES completion:nil];
//    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)loginAction:(id)sender {
    if ([NSString isBlankString:self.userNameTf.text]) {
        [SVProgressHUD showInfoWithStatus:@"请输入用户名"];
        return;
    }
    if ([NSString isBlankString:self.secrectTf.text]) {
        [SVProgressHUD showInfoWithStatus:@"请输入密码"];
        return;
    }
    NSDictionary *param = @{@"loginAccount":self.userNameTf.text,@"loginPwd":self.secrectTf.text};
    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerUrl apiPath:@"/openHikApi/server/app/login" header:nil parameters:param progress:^(NSProgress * _Nullable progress) {
        
    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
        if ([responseObject[@"code"] isEqual: @"0000"]) {
            NSDictionary *dic = responseObject[@"data"];
            LKUserInfor *userInfor = [LKUserInfor accountWithDict:dic];
            [LKUserInforTool saveAccount:userInfor];
            [LKSwitchRootVcTool switchRootController];
            [LKPushSetModel setUpMyPushInfo];
        }else{
            [SVProgressHUD showInfoWithStatus:responseObject[@"msg"]];
        }
        

    } failure:^(NSString * _Nullable errorMessage) {
        
    }];


}
- (IBAction)showOrHidenInputSecrectAction:(id)sender {
    UIButton *btn = (UIButton *)sender;
    btn.selected = !btn.selected;
    self.secrectTf.secureTextEntry = !self.secrectTf.secureTextEntry;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
